package com.hellobike.haxing.modules.order.service.impl;

import com.hellobike.haxing.modules.order.entity.OrderAftersaleDetail;
import com.hellobike.haxing.modules.order.mapper.OrderAftersaleDetailMapper;
import com.hellobike.haxing.modules.order.service.IOrderAftersaleDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Description: 售后订单明细
 * @Author: haxing-boot
 * @Date:   2020-02-08
 * @Version: V1.0
 */
@Service
public class OrderAftersaleDetailServiceImpl extends ServiceImpl<OrderAftersaleDetailMapper, OrderAftersaleDetail> implements IOrderAftersaleDetailService {
    @Autowired
    private OrderAftersaleDetailMapper orderAftersaleDetailMapper;
    @Override
    public Map<Long, BigDecimal> queryOrderDetailReturnAmount(Long orderId) {
        List<OrderAftersaleDetail> list = orderAftersaleDetailMapper.queryDetailStatusSuccess(orderId);
        return list.stream().collect(Collectors.toMap(OrderAftersaleDetail::getOrderDetailId,detail -> detail.getAfterAmount()));
    }
}
